package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.pressureMonitor.*;
import com.hzhr.iot.device.service.PressureMonitorService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "PressureMonitor", description = "压力监测仪")
@RestController
@RequestMapping(value = "")
public class PressureMonitorController extends BaseController {
    @Autowired
    PressureMonitorService pressureMonitorService;

    //region /pressure-monitors POST
    //region swagger响应码 : post
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : post
    @ApiOperation(value="实施档案-创建流量计台账", notes="实施档案-创建流量计台账  \n简介 : 创建压力监测仪采集台账；关联对应的物联台账及燃气用户  \n步骤 :  \n1. 系统权限：根据燃气用户代码和部门编号查询“燃气用户_1”，如果“燃气用户_1”不存在，抛出异常“燃气用户不存在”；(√)  \n2. 系统权限：根据压力监测仪代码查询“压力监测仪物联台账_1”，如果“压力监测仪物联台账_1”不存在，抛出异常“压力监测仪物联台账不存在”; (√)  \n3. 系统权限：根据压力监测仪代码和燃气公司编号查询“压力监测仪采集台账_1”，如果“压力监测仪采集台账_1”存在，抛出异常“压力监测仪代码已存在”; (√)  \n4. 系统权限：在燃气公司和部门下创建“压力监测仪采集台账_2”，并关联“压力监测仪物联台账_1”和“燃气用户_1”; (√)  \n",produces = "application/json")
    //endregion
    //region swagger参数 : post
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),
    })
    //endregion
    //region 请求 : post
    @RequestMapping(value = "/pressure-monitors", method = RequestMethod.POST)
    //endregion
    @Author
    public ResponseEntity<PressureMonitorPostResponseModel> post(@RequestParam @ApiIgnore Map<String, Object> query,
                                                                 @RequestBody PressureMonitorPostModel body) throws ServiceException {
        PressureMonitorPostResponseModel responseBody = pressureMonitorService.post(initHeader(), query, body);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
    //region /pressure-monitors DELETE
    //region swagger响应码 : delete
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : delete
    @ApiOperation(value="实施档案-删除压力检测仪台账", notes="实施档案-删除压力检测仪台账  \n简介 : 删除压力监测仪采集台账  \n步骤 :  \n1. 系统权限：根据压力监测仪编号查询“压力监测仪采集台账_1”，如“压力监测仪采集台账_1”不存在，抛出异常“压力监测仪采集台账不存在”; (√)  \n2. 系统权限：删除“压力监测仪采集台账_1”; (√)  \n",produces = "application/json")
    //endregion
    //region swagger参数 : delete
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),
    })
    //endregion
    //region 请求 : delete
    @RequestMapping(value = "/pressure-monitors", method = RequestMethod.DELETE)
    //endregion
    @Author
    public ResponseEntity<PressureMonitorDeleteResponseModel> delete(@RequestParam @ApiIgnore Map<String, Object> query,
                                                                     @RequestBody PressureMonitorDeleteModel body) throws ServiceException {
        PressureMonitorDeleteResponseModel responseBody = pressureMonitorService.delete(initHeader(), query, body);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
    //region /pressure-monitors PUT
    //region swagger响应码 : put
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : put
    @ApiOperation(value="实施档案-修改流量计台账", notes="实施档案-修改流量计台账  \n简介 : 修改压力监测仪采集台账；关联对应的物联台账及燃气用户  \n步骤 :  \n1. 系统权限：根据压力监测仪编号查询“压力监测仪采集台账_1”，如果“压力监测仪采集台账_1”不存在，抛出异常“压力监测仪采集台账不存在”; (√)  \n2. 系统权限：如果压力监测仪代码与“压力监测仪采集台账_1”的代码不同，则根据压力监测仪代码查询“压力监测仪物联台账_1”，如果“压力监测仪物联台账_1”不存在，抛出异常“新的压力检测物联台账不存在”，然后根据压力监测仪代码和燃气公司编号查询“压力监测仪采集台账_2”，如果“压力监测仪采集台账_2”存在，则抛出异常“新的压力监测仪代码已存在”; (√)  \n3. 系统权限：如果燃气用户代码和“压力监测仪采集台账_1”的燃气用户代码不同，则根据燃气用户代码和部门编号查询“燃气用户_1”，如果“燃气用户_1”不存在，抛出异常“燃气用户不存在”；(√)  \n4. 系统权限：更新“压力监测仪采集台账_1”的信息，如果压力监测仪代码与“压力监测仪采集台账_1”的代码不同，关联“压力监测仪采集台账_1”和“压力监测仪物联台账_1”，如果燃气用户代码和“压力监测仪采集台账_1”的燃气用户代码不同，关联“压力监测仪采集台账_1”和“燃气用户_1”; (√)  \n",produces = "application/json")
    //endregion
    //region swagger参数 : put
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),
    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),
    })
    //endregion
    //region 请求 : put
    @RequestMapping(value = "/pressure-monitors", method = RequestMethod.PUT)
    //endregion
    @Author
    public ResponseEntity<PressureMonitorPutResponseModel> put(@RequestParam @ApiIgnore Map<String, Object> query,
                                                               @RequestBody PressureMonitorPutModel body) throws ServiceException {
        PressureMonitorPutResponseModel responseBody = pressureMonitorService.put(initHeader(), query, body);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
}
















































































































































































































































































































































































































































































































































































































































































